Physics 215 Mini-project 1st Semester A.Y. 2022-2023
Members:
Main Contribution
Note: The PDF submission will show a snapshot of the simulations and the animations are included in the submission.
using Pkg;
Pkg.activate(".")
Pkg.add("QuantumOptics")
Pkg.add("Plots")
Pkg.add("LaTeXStrings")
Pkg.add("FFTW")
Pkg.add("BenchmarkTools");
Pkg.add("StatsBase")
Pkg.update()
Pkg.status()
using QuantumOptics
using Plots
using LaTeXStrings
using FFTW
using BenchmarkTools
using StatsBase
Activating new project at `~/Desktop/Physics215_MiniProject` Updating registry at `~/.julia/registries/General.toml` Resolving package versions... Updating `~/Desktop/Physics215_MiniProject/Project.toml` [6e0679c1] + QuantumOptics v1.0.8 Updating `~/Desktop/Physics215_MiniProject/Manifest.toml` [621f4979] + AbstractFFTs v1.2.1 [79e6a3ab] + Adapt v3.4.0 [ec485272] + ArnoldiMethod v0.2.0 ⌅ [7d9fca2a] + Arpack v0.5.3 [4fba245c] + ArrayInterface v6.0.24 [30b0a656] + ArrayInterfaceCore v0.1.28 [6ba088a2] + ArrayInterfaceGPUArrays v0.2.2 [015c0d05] + ArrayInterfaceOffsetArrays v0.1.7 [b0d46f97] + ArrayInterfaceStaticArrays v0.1.5 [dd5226c6] + ArrayInterfaceStaticArraysCore v0.1.3 [62783981] + BitTwiddlingConvenienceFunctions v0.1.5 [2a0fbf3d] + CPUSummary v0.2.1 [49dc2e85] + Calculus v0.5.1 [d360d2e6] + ChainRulesCore v1.15.6 [9e997f8a] + ChangesOfVariables v0.1.4 [fb6a15b2] + CloseOpenIntervals v0.1.11 [38540f10] + CommonSolve v0.2.3 [bbf7d656] + CommonSubexpressions v0.3.0 [34da2185] + Compat v4.5.0 [187b0558] + ConstructionBase v1.4.1 [adafc99b] + CpuId v0.3.1 [9a962f9c] + DataAPI v1.14.0 [864edb3b] + DataStructures v0.18.13 [e2d170a0] + DataValueInterfaces v1.0.0 [b429d917] + DensityInterface v0.4.0 [2b5f629d] + DiffEqBase v6.113.1 [459566f4] + DiffEqCallbacks v2.24.3 [77a26b50] + DiffEqNoiseProcess v5.15.2 [163ba53b] + DiffResults v1.1.0 [b552c78f] + DiffRules v1.12.2 [b4f34e82] + Distances v0.10.7 [31c24e10] + Distributions v0.25.80 [ffbed154] + DocStringExtensions v0.9.3 [fa6b7ba4] + DualNumbers v0.6.8 [4e289a0a] + EnumX v1.0.4 [d4d017d3] + ExponentialUtilities v1.22.0 [e2ba6199] + ExprTools v0.1.8 [7a1cc6ca] + FFTW v1.5.0 [7034ab61] + FastBroadcast v0.2.4 [9aa1b823] + FastClosures v0.3.2 [29a986be] + FastLapackInterface v1.2.8 [1a297f60] + FillArrays v0.13.6 [6a86dc24] + FiniteDiff v2.17.0 [f6369f11] + ForwardDiff v0.10.34 [069b7b12] + FunctionWrappers v1.1.3 [77dc65aa] + FunctionWrappersWrappers v0.1.1 [46192b85] + GPUArraysCore v0.1.2 [c145ed77] + GenericSchur v0.5.3 [86223c79] + Graphs v1.7.4 [f0d1745a] + HalfIntegers v1.4.3 [3e5b6fbb] + HostCPUFeatures v0.1.13 [34004b35] + HypergeometricFunctions v0.3.11 [615f187c] + IfElse v0.1.1 [d25df0c9] + Inflate v0.1.3 [18e54dd8] + IntegerMathUtils v0.1.0 [3587e190] + InverseFunctions v0.1.8 [92d709cd] + IrrationalConstants v0.1.1 [42fd0dbc] + IterativeSolvers v0.9.2 [82899510] + IteratorInterfaceExtensions v1.0.0 [692b3bcd] + JLLWrappers v1.4.1 [ccbc3e58] + JumpProcesses v9.3.1 [ef3ab10e] + KLU v0.4.0 [ba0b0d4f] + Krylov v0.9.0 [0b1a1467] + KrylovKit v0.6.0 [8ac3fa9e] + LRUCache v1.4.0 [10f19ff3] + LayoutPointers v0.1.12 [2d8b4e74] + LevyArea v1.0.0 [d3d80556] + LineSearches v7.2.0 [7a12625a] + LinearMaps v3.8.0 [7ed4a6bd] + LinearSolve v1.33.0 [2ab3a3ac] + LogExpFunctions v0.3.19 [bdcacae8] + LoopVectorization v0.12.146 [1914dd2f] + MacroTools v0.5.10 [d125e4d3] + ManualMemory v0.1.8 [e1d29d7a] + Missings v1.1.0 [46d2c3a1] + MuladdMacro v0.2.4 [d41bc354] + NLSolversBase v7.8.3 [2774e3e8] + NLsolve v4.5.1 [77ba4419] + NaNMath v1.0.1 [8913a72c] + NonlinearSolve v1.1.1 [6fe1bfb0] + OffsetArrays v1.12.8 [429524aa] + Optim v1.7.4 [bac558e1] + OrderedCollections v1.4.1 [1dea7af3] + OrdinaryDiffEq v6.37.0 [90014a1f] + PDMats v0.11.16 [d96e819e] + Parameters v0.12.3 [e409e4f3] + PoissonRandom v0.4.3 [f517fe37] + Polyester v0.7.1 [1d0040c9] + PolyesterWeave v0.2.0 [85a6dd25] + PositiveFactorizations v0.2.4 [d236fae5] + PreallocationTools v0.4.8 [21216c6a] + Preferences v1.3.0 [27ebfcd6] + Primes v0.5.3 [1fd47b50] + QuadGK v2.6.0 [5717a53b] + QuantumInterface v0.1.0 [6e0679c1] + QuantumOptics v1.0.8 [4f57444f] + QuantumOpticsBase v0.3.8 [74087812] + Random123 v1.6.0 [e6cf234a] + RandomNumbers v1.5.3 [308eb6b3] + RationalRoots v0.2.0 [3cdcf5f2] + RecipesBase v1.3.3 [731186ca] + RecursiveArrayTools v2.35.0 [f2c3362d] + RecursiveFactorization v0.2.15 [189a3867] + Reexport v1.2.2 [ae029012] + Requires v1.3.0 [ae5879a3] + ResettableStacks v1.1.1 [79098fc4] + Rmath v0.7.0 [7e49a35a] + RuntimeGeneratedFunctions v0.5.5 [3cdde19b] + SIMDDualNumbers v0.1.1 [94e857df] + SIMDTypes v0.1.0 [476501e8] + SLEEFPirates v0.6.37 [0bca4576] + SciMLBase v1.81.0 [e9a6253c] + SciMLNLSolve v0.1.1 [efcf1570] + Setfield v1.1.1 [727e6d20] + SimpleNonlinearSolve v0.1.4 [699a6c99] + SimpleTraits v0.9.4 [66db9d55] + SnoopPrecompile v1.0.3 [a2af1166] + SortingAlgorithms v1.1.0 [47a9eef4] + SparseDiffTools v1.30.0 [e56a9233] + Sparspak v0.3.4 [276daf66] + SpecialFunctions v2.1.7 [aedffcd0] + Static v0.8.3 [90137ffa] + StaticArrays v1.5.12 [1e83bf80] + StaticArraysCore v1.4.0 [82ae8749] + StatsAPI v1.5.0 [2913bbd2] + StatsBase v0.33.21 [4c63d2b9] + StatsFuns v1.1.1 [789caeaf] + StochasticDiffEq v6.57.4 [7792a7ef] + StrideArraysCore v0.4.5 [5e0ebb24] + Strided v1.2.3 [2efcf032] + SymbolicIndexingInterface v0.2.1 [3783bdb8] + TableTraits v1.0.1 [bd369af6] + Tables v1.10.0 [8290d209] + ThreadingUtilities v0.5.0 [a2a6695c] + TreeViews v0.3.0 [d5829a12] + TriangularSolve v0.1.17 [410a4b4d] + Tricks v0.1.6 [9d95972d] + TupleTools v1.3.0 [3a884ed6] + UnPack v1.0.2 [c4a57d5a] + UnsafeArrays v1.0.4 [3d5dd08c] + VectorizationBase v0.21.57 [19fa3120] + VertexSafeGraphs v0.2.0 [9f57e263] + WignerSymbols v2.0.0 [700de1a5] + ZygoteRules v0.2.2 ⌅ [68821587] + Arpack_jll v3.5.1+1 [f5851436] + FFTW_jll v3.3.10+0 [1d5cc7b8] + IntelOpenMP_jll v2018.0.3+2 [856f044c] + MKL_jll v2022.2.0+0 [efe28fd5] + OpenSpecFun_jll v0.5.5+0 [f50d1b31] + Rmath_jll v0.3.0+0 [0dad84c5] + ArgTools v1.1.1 [56f22d72] + Artifacts [2a0f44e3] + Base64 [ade2ca70] + Dates [8ba89e20] + Distributed [f43a241f] + Downloads v1.6.0 [7b1f6079] + FileWatching [9fa8497b] + Future [b77e0a4c] + InteractiveUtils [4af54fe1] + LazyArtifacts [b27032c2] + LibCURL v0.6.3 [76f85450] + LibGit2 [8f399da3] + Libdl [37e2e46d] + LinearAlgebra [56ddb016] + Logging [d6f4376e] + Markdown [a63ad114] + Mmap [ca575930] + NetworkOptions v1.2.0 [44cfe95a] + Pkg v1.8.0 [de0858da] + Printf [3fa0cd96] + REPL [9a3f8284] + Random [ea8e919c] + SHA v0.7.0 [9e88b42a] + Serialization [1a1011a3] + SharedArrays [6462fe0b] + Sockets [2f01184e] + SparseArrays [10745b16] + Statistics [4607b0f0] + SuiteSparse [fa267f1f] + TOML v1.0.0 [a4e569a6] + Tar v1.10.0 [8dfed614] + Test [cf7118a7] + UUIDs [4ec0a83e] + Unicode [e66e0078] + CompilerSupportLibraries_jll v0.5.2+0 [deac9b47] + LibCURL_jll v7.84.0+0 [29816b5a] + LibSSH2_jll v1.10.2+0 [c8ffd9c3] + MbedTLS_jll v2.28.0+0 [14a3606d] + MozillaCACerts_jll v2022.2.1 [4536629a] + OpenBLAS_jll v0.3.20+0 [05823500] + OpenLibm_jll v0.8.1+0 [bea87d4a] + SuiteSparse_jll v5.10.1+0 [83775a58] + Zlib_jll v1.2.12+3 [8e850b90] + libblastrampoline_jll v5.1.1+0 [8e850ede] + nghttp2_jll v1.48.0+0 [3f19e933] + p7zip_jll v17.4.0+0 Info Packages marked with ⌅ have new versions available but cannot be upgraded. To see why use `status --outdated -m` Resolving package versions... Updating `~/Desktop/Physics215_MiniProject/Project.toml` [91a5bcdd] + Plots v1.38.2 Updating `~/Desktop/Physics215_MiniProject/Manifest.toml` [d1d4a3ce] + BitFlags v0.1.7 [944b1d66] + CodecZlib v0.7.0 [35d6a980] + ColorSchemes v3.20.0 [3da002f7] + ColorTypes v0.11.4 [c3611d14] + ColorVectorSpace v0.9.10 [5ae59095] + Colors v0.12.10 [d38c429a] + Contour v0.6.2 [c87230d0] + FFMPEG v0.4.1 [53c48c17] + FixedPointNumbers v0.8.4 [59287772] + Formatting v0.4.2 [28b8d3ca] + GR v0.71.3 [42e2da0e] + Grisu v1.0.2 [cd3eb016] + HTTP v1.7.1 [83e8ac13] + IniFile v0.5.1 [1019f520] + JLFzf v0.1.5 [682c06a0] + JSON v0.21.3 [b964fa9f] + LaTeXStrings v1.3.0 [23fbe1c1] + Latexify v0.15.18 [e6f89c97] + LoggingExtras v1.0.0 [739be429] + MbedTLS v1.1.7 [442fdcdd] + Measures v0.3.2 [4d8831e6] + OpenSSL v1.3.3 [69de0a69] + Parsers v2.5.3 [b98c9c47] + Pipe v1.3.0 [ccf2f8ad] + PlotThemes v3.1.0 [995b91a9] + PlotUtils v1.3.2 [91a5bcdd] + Plots v1.38.2 [01d81517] + RecipesPipeline v0.6.11 [05181044] + RelocatableFolders v1.0.0 [6c6a2e73] + Scratch v1.1.1 [992d4aef] + Showoff v1.0.3 [777ac1f9] + SimpleBufferStream v1.1.0 [62fd8b95] + TensorCore v0.1.1 [3bb67fe8] + TranscodingStreams v0.9.11 [5c2747f8] + URIs v1.4.1 [1cfade01] + UnicodeFun v0.4.1 [41fe7b60] + Unzip v0.2.0 [6e34b625] + Bzip2_jll v1.0.8+0 [83423d85] + Cairo_jll v1.16.1+1 [2e619515] + Expat_jll v2.4.8+0 [b22a6f82] + FFMPEG_jll v4.4.2+2 [a3f928ae] + Fontconfig_jll v2.13.93+0 [d7e528f0] + FreeType2_jll v2.10.4+0 [559328eb] + FriBidi_jll v1.0.10+0 [0656b61e] + GLFW_jll v3.3.8+0 [d2c73de3] + GR_jll v0.71.3+0 [78b55507] + Gettext_jll v0.21.0+0 [7746bdde] + Glib_jll v2.74.0+2 [3b182d85] + Graphite2_jll v1.3.14+0 [2e76f6c2] + HarfBuzz_jll v2.8.1+1 [aacddb02] + JpegTurbo_jll v2.1.2+0 [c1c5ebd0] + LAME_jll v3.100.1+0 [88015f11] + LERC_jll v3.0.0+1 [dd4b983a] + LZO_jll v2.10.1+0 ⌅ [e9f186c6] + Libffi_jll v3.2.2+1 [d4300ac3] + Libgcrypt_jll v1.8.7+0 [7e76a0d4] + Libglvnd_jll v1.6.0+0 [7add5ba3] + Libgpg_error_jll v1.42.0+0 [94ce4f54] + Libiconv_jll v1.16.1+2 [4b2f31a3] + Libmount_jll v2.35.0+0 [89763e89] + Libtiff_jll v4.4.0+0 [38a345b3] + Libuuid_jll v2.36.0+0 [e7412a2a] + Ogg_jll v1.3.5+1 [458c3c95] + OpenSSL_jll v1.1.19+0 [91d4177d] + Opus_jll v1.3.2+0 [30392449] + Pixman_jll v0.40.1+0 [ea2cea3b] + Qt5Base_jll v5.15.3+2 [a2964d1f] + Wayland_jll v1.21.0+0 [2381bf8a] + Wayland_protocols_jll v1.25.0+0 [02c8fc9c] + XML2_jll v2.10.3+0 [aed1982a] + XSLT_jll v1.1.34+0 [4f6342f7] + Xorg_libX11_jll v1.6.9+4 [0c0b7dd1] + Xorg_libXau_jll v1.0.9+4 [935fb764] + Xorg_libXcursor_jll v1.2.0+4 [a3789734] + Xorg_libXdmcp_jll v1.1.3+4 [1082639a] + Xorg_libXext_jll v1.3.4+4 [d091e8ba] + Xorg_libXfixes_jll v5.0.3+4 [a51aa0fd] + Xorg_libXi_jll v1.7.10+4 [d1454406] + Xorg_libXinerama_jll v1.1.4+4 [ec84b674] + Xorg_libXrandr_jll v1.5.2+4 [ea2f1a96] + Xorg_libXrender_jll v0.9.10+4 [14d82f49] + Xorg_libpthread_stubs_jll v0.1.0+3 [c7cfdc94] + Xorg_libxcb_jll v1.13.0+3 [cc61e674] + Xorg_libxkbfile_jll v1.1.0+4 [12413925] + Xorg_xcb_util_image_jll v0.4.0+1 [2def613f] + Xorg_xcb_util_jll v0.4.0+1 [975044d2] + Xorg_xcb_util_keysyms_jll v0.4.0+1 [0d47668e] + Xorg_xcb_util_renderutil_jll v0.3.9+1 [c22f9ab0] + Xorg_xcb_util_wm_jll v0.4.1+1 [35661453] + Xorg_xkbcomp_jll v1.4.2+4 [33bec58e] + Xorg_xkeyboard_config_jll v2.27.0+4 [c5fb5394] + Xorg_xtrans_jll v1.4.0+3 [3161d3a3] + Zstd_jll v1.5.2+0 ⌅ [214eeab7] + fzf_jll v0.29.0+0 [a4ae2306] + libaom_jll v3.4.0+0 [0ac62f75] + libass_jll v0.15.1+0 [f638f0a6] + libfdk_aac_jll v2.0.2+0 [b53b4c65] + libpng_jll v1.6.38+0 [f27f6e37] + libvorbis_jll v1.3.7+1 [1270edf5] + x264_jll v2021.5.5+0 [dfaa095f] + x265_jll v3.5.0+0 [d8fb68d0] + xkbcommon_jll v1.4.1+0 [8bb1440f] + DelimitedFiles [efcefdf7] + PCRE2_jll v10.40.0+0 Info Packages marked with ⌅ have new versions available but cannot be upgraded. To see why use `status --outdated -m` Resolving package versions... Updating `~/Desktop/Physics215_MiniProject/Project.toml` [b964fa9f] + LaTeXStrings v1.3.0 No Changes to `~/Desktop/Physics215_MiniProject/Manifest.toml` Resolving package versions... Updating `~/Desktop/Physics215_MiniProject/Project.toml` [7a1cc6ca] + FFTW v1.5.0 No Changes to `~/Desktop/Physics215_MiniProject/Manifest.toml` Resolving package versions... Updating `~/Desktop/Physics215_MiniProject/Project.toml` [6e4b80f9] + BenchmarkTools v1.3.2 Updating `~/Desktop/Physics215_MiniProject/Manifest.toml` [6e4b80f9] + BenchmarkTools v1.3.2 [9abbd945] + Profile Resolving package versions... Updating `~/Desktop/Physics215_MiniProject/Project.toml` [2913bbd2] + StatsBase v0.33.21 No Changes to `~/Desktop/Physics215_MiniProject/Manifest.toml` Updating registry at `~/.julia/registries/General.toml` No Changes to `~/Desktop/Physics215_MiniProject/Project.toml` No Changes to `~/Desktop/Physics215_MiniProject/Manifest.toml`
Status `~/Desktop/Physics215_MiniProject/Project.toml` [6e4b80f9] BenchmarkTools v1.3.2 [7a1cc6ca] FFTW v1.5.0 [b964fa9f] LaTeXStrings v1.3.0 [91a5bcdd] Plots v1.38.2 [6e0679c1] QuantumOptics v1.0.8 [2913bbd2] StatsBase v0.33.21
┌ Info: Precompiling Plots [91a5bcdd-55d7-5caf-9e0b-520d859cae80] └ @ Base loading.jl:1662 ┌ Warning: backend `GR` is not installed. └ @ Plots ~/.julia/packages/Plots/nuwp4/src/backends.jl:37 [ Info: GR
In this mini-project, we aim to simulate a one-dimensional closed quantum system with a Harmonic trap. The Hamiltonian simulated is \begin{equation} \hat{H} = \frac{\hat{p}^2}{2m}+\frac{m\omega^2\hat{x}^2}{2}\label{1} \end{equation} where $\hat{x}$ ($\hat{p}$) is the position (momentum) operator, $m$ is the mass, and $\omega$ is the strength of the trap. In our discussion and simulation, we let the constant $\hbar$ to be 1.
We first implement the given Hamiltonian using the QuantumOptics package in Julia by Krämer et al. (2018) [1]. Do note that for us to simulate a quantum system, we must first define the operators, bases, and set up the Hamiltonian. We can simulate both closed and open quantum systems. However, in this project, we will only be focusing on closed systems. One advantage of the QuantumOptics package is that it takes into account the Hilbert space where the operators and basis are. Another advantage of the package is that it is entirely written in Julia and is open-source.
The documentation of the library can be found in QuantumOptics.jl documentation.
First we determine the basis states for the position and momentum space using a given system parameters. These bases are specified to assign the Hilbert space of the system where the bases are present to avoid combining bases present in different Hilbert space. By using the PositionBasis and MomentumBasis, we instruct that these bases should be calculated in real and momentum space, respectively. Note that we include both the position and momentum bases since we plan on having the algorithm use a Fourier transform. Afterwards, we define an operator in Julia. Note that an operator in Julia refers to the coefficients $A_{ij}$ of the abstract operator
\begin{equation}
A = \sum_{ij} A_{ij} |{u_i}\rangle\langle v_j|.
\end{equation}
# System Parameters
m::Float64 = 1.0 # Mass
ω::Float64 = 2.0 # Strength of trapping potential
# Range for position
xmin::Float64 = -4.0
xmax::Float64 = 4.0
Npoints::Int64 = 200;
# Basis
b_x = PositionBasis(xmin, xmax, Npoints);
b_p = MomentumBasis(b_x);
# operators
x_op = position(b_x);
p_op = momentum(b_p);
We want to utilize the fast Fourier transformation to simulate the system. We do this by implementing the function transform(). This lets us change between the real and momentum space of our system by converting the position to momentum operator and vice versa. This comes from the idea that the momentum operator is just the Fourier transform of the position operator. Note that if we only focus on the real or momentum space, the calculations will scale $N^2$ for $N$ dimension.
The function dagger(x) returns the Hermitian conjugate of x or by transforming the ket state as bra state.
px = transform(b_p, b_x) # position to momentum
xp = dagger(px)
FFTOperators(dim=200x200) basis left: Position(xmin=-4.0, xmax=4.0, N=200) basis right: Momentum(pmin=-78.53981633974483, pmax=78.53981633974483, N=200)
Then, we proceed on defining our Hamiltonian by using Lazy Operators. The Lazy operators lets us conduct an operation with a different order. For example, the LazyProduct(A,B,C) simplifies $A*(B*C)$ which is useful for terms like $ \mathrm{IFFT}*(D*(\mathrm{FFT}*\psi))$. Notice that the right basis for ($\mathrm{FFT}*\psi$) is now the momentum basis. This will be used to the kinetic energy part of the Hamiltonian. Hence, the Hamiltonian is a LazySum of the LazyProduct kinetic energy and the potential energy.
K = LazyProduct(xp, p_op^2/2m, px)
V = ω^2*x_op^2*m/2
H = LazySum(K, V)
LazySum(dim=200x200) basis: Position(xmin=-4.0, xmax=4.0, N=200) operators: 2
Next, we define the initial state as a Gaussian function using the function gaussianstate(x, p, sigma) where the Gaussian state is initially at x for real space, and p for the momentum space with width sigma. The gaussianstate(x0, p0, sigma), where sigma is $\sigma$, is given by
\begin{equation}
\Psi_0(x) = \frac{1}{\pi^{1/4}\sqrt{\sigma}}e^{ip_0\left(x-\frac{x_0}{2}\right)-\frac{(x-x_0)^2}{2\sigma^2}}.
\end{equation}
Note that to show the time evolution of $\Psi$, we chose to not use the analytic initial state or the ground state. We do this by shifting the initial state away from the center of the harmonic trap.
x0::Float64 = 2.0
p0::Float64 = 0.0
sigma = (1/(m*ω))^(1/2)
psi0 = gaussianstate(b_x, x0, p0, sigma);
To get a better look of the initial state, we plot the probability distribution of the initial gaussian state and the harmonic trap potential.
x_points = samplepoints(b_x) # Values of th position
n = abs.(psi0.data).^2 # Probability
V0 = (ω^2*x_points.^2*m/2)/maximum(ω^2*x_points.^2*m/2)*maximum(abs.(psi0.data).^2) # Scaled trapping potential
plt = plot(x_points, n, lc=:black, label = false)
plt = plot!(x_points,V0, lc=:gray, linestyle = :dash, xlabel =L"x", ylabel = L"| \Psi(x,t) |^2", label = "trap" )
display(plt)
Finally, we solve for the time evolution of the Schroedinger equation with a harmonic trap for a closed quantum system using the function in the QuantumOptics package timeevolution.schroedinger(t, psi0, H). Note that t is the time interval for the simulation, psi0 is the initial state, and H is the Hamiltonian. The function solves the Schroedinger equation as defined below
\begin{gather}
i\hbar \frac{d}{dt}|\Psi(t)\rangle = H|\Psi(t)\rangle\\
i\hbar \frac{d}{dt}\langle\Psi(t)| = H\langle\Psi(t)|.
\end{gather}
One of the two possible implementations is chosen by Julia depending on the initial state.
time = [0:0.01:10;]
t, psi_t = timeevolution.schroedinger(time, psi0, H);
Then we animate to show the evolution of $\Psi(t)$ to confirm that the simulation worked. Moreover, we also showed the probability distribution $|\Psi(t)|^2$. We note that from the simulations, the distribution of $\Psi(t)$ mainly remains inside the trap, and is moving back and forth instead of moving outside.
FPS = 10
# Scaled trapping potential for plotting purposes
V1 = (ω^2*x_points.^2*m/2)/maximum(ω^2*x_points.^2*m/2)*maximum(abs2.(psi0.data))
pt = @animate for i=1:length(time)
psi = psi_t[i]
plot(x_points,abs.(psi.data).^2 , lc=:black, label = "t =$(i)",
yaxis=("y", (0., 0.05)), legend =:topright);
plot!(x_points, real.(psi.data).^2, lc=:red, label = L"Re\{ \Psi(x,t) \}^2",
legend =:topright);
plot!(x_points, imag.(psi.data).^2, lc=:blue, label = L"Im\{ \Psi(x,t) \}^2",
legend =:topright);
plot!(x_points,V1, lc=:gray, linestyle = :dash, xlabel =L"x", ylabel = L"| \Psi(x,t) |^2", label = "trap", legend =:topright);
end every 10
gif(pt, "KR1_time_evol.gif", fps = FPS)
┌ Info: Saved animation to /Users/richellejadetuquero/Desktop/Physics215_MiniProject/KR1_time_evol.gif └ @ Plots /Users/richellejadetuquero/.julia/packages/Plots/nuwp4/src/animation.jl:156
To show that using the ground state would result to a steady state. We implement the same process using the ground state as the initial state. Note that the ground state or the exact solution for the Hamiltonian in Eq. \eqref{1} is \begin{equation} \Psi_0(x) = \frac{\sqrt{m\omega}}{\pi^{1/4}}e^{-\frac{m\omega x^2}{2}}. \end{equation}
x0::Float64 = 0.0
p0::Float64 = 0.0
sigma = (1/(m*ω))^(1/2)
psi0 = gaussianstate(b_x, x0, p0, sigma);
t, psi_t = timeevolution.schroedinger(time, psi0, H);
pt = @animate for i=1:length(time)
psi = psi_t[i]
plot(x_points, abs.(psi.data).^2, lc=:black, label = "t =$(i)",
yaxis=("y", (0., 0.05)), legend =:topright);
plot!(x_points, real.(psi.data).^2, lc=:red, label = L"Re\{ \Psi(x,t) \}^2",
legend =:topright);
plot!(x_points, imag.(psi.data).^2, lc=:blue, label = L"Im\{ \Psi(x,t) \}^2",
legend =:topright);
plot!(x_points,V0, lc=:gray, linestyle = :dash, xlabel =L"x", ylabel = L"| \Psi(x,t) |^2" ,
label = "trap", legend =:topright);
end every 10
gif(pt, "KR1_ground.gif", fps = 10)
┌ Info: Saved animation to /Users/richellejadetuquero/Desktop/Physics215_MiniProject/KR1_ground.gif └ @ Plots /Users/richellejadetuquero/.julia/packages/Plots/nuwp4/src/animation.jl:156
As shown in the result, we observe that $\Psi(x,t)$ does not change in time which shows that this is a steady state. This confirms that the simulation is correct since the system is in the ground state.
Split operator method is discussed on chapter 16 of An Introduction to Computer Simulation Methods 3rd ed. [2]. Here we use $\hbar=m=1\Rightarrow h=2\pi$.
The time-dependent Schrodinger equation is given by
\begin{equation} i\frac{\partial\Psi(x,t)}{\partial t}=\hat{H}\Psi(x,t)=\left(\hat T+\hat V\right)\Psi(x,t). \end{equation}The formal solution to this is \begin{equation} \Psi(x,t)=\hat{U}\Psi(x,t_0), \end{equation} where $\hat U$ is the time evolution operator \begin{equation} \hat U=e^{i\hat H(t-t_0)}=e^{i\left(\hat T+\hat V\right)(t-t_0)}. \end{equation}
So the goal of the algorithm is to create a numerical version of this operator.
For the algorithm, we note the time evolution operator for $\hat T$ and $\hat V$ individually. For $\hat V$, the time evolution in position space is \begin{equation} \Psi(x, t+\Delta t)=e^{-iV(x)\Delta t}\Psi(x, t). \end{equation} For $\hat T$, the time evolution in momentum space is \begin{equation} \Psi(p, t+\Delta t)=e^{-ip^2\Delta t/2}\Psi(p, t). \end{equation}
Then, by De Broglie, \begin{equation} p=hf=2\pi f. \end{equation} This means that we can simply take the Fourier transform $F$ and its inverse $F^{-1}$ of the wavefunction to move back and forth between the position and momentum space. So what we can do is to evolve a half timestep in position, then a full timestep in momentum, and another half timestep in position to get the total time evolution. The time evolution operator is then \begin{equation} \hat U=e^{-iV(x)\Delta t/2}F^{-1}e^{-ip^2\Delta t/2}Fe^{-iV(x)\Delta t/2} \end{equation}
x_coeff(V::Vector{ComplexF64}, Δt::Float64) = exp.(-im*V*Δt/2) # Creates the coefficient for position evolution
p_coeff(p::Vector{ComplexF64}, Δt::Float64) = exp.(-im*(p.^2)*Δt/(2)) # Creates the coefficient for momentum evolution
p_coeff (generic function with 1 method)
function SplitStep(ψ, V, p, t_points; potential_evolution=x_coeff, kinetic_evolution=p_coeff)
#=
ψ: initial wavefunction
V: time independent potential
p: momentum
T: total time
Δt: time-step
=#
Δt = t_points[2]-t_points[1]
output = Array{Complex}(undef, length(t_points), length(ψ))
# Creates the empty output array. 1st dimension is time, including initial wvfcn, 2nd is position.
for (i, t) in enumerate(t_points)
output[i,:]=ψ[:] # Inputs the current content of ψ into the output
ψ=fft(potential_evolution(V, Δt).*ψ)
ψ=ifft(kinetic_evolution(p, Δt).*ψ)
ψ=potential_evolution(V,Δt).*ψ
end
output
end
SplitStep (generic function with 1 method)
First we create the position values vector, using the same parameters as in the previous KR.
x = Vector{ComplexF64}(x_points);
Then, the momentum values, which is created using fftfreq, which automatically creates the frequencies for the Fourier transform.
p = 2π.*Vector{ComplexF64}(fftfreq(length(x), length(x)/abs(x[1]-x[end])));
We then create the parameters for the split step, where we use the quantum harmonic oscillator with the initial wavefunction as the ground state solution.
Δx = x[2]-x[1]
p = 2π.*Vector{ComplexF64}(fftfreq(length(x), length(x)/abs(x[1]-x[end])));
x0::Float64 = 2.0
p0::Float64 = 0.0
ψ = (sqrt(Δx)/(sqrt(sigma)*(π)^(1/4)))*exp.(im*p0*(x.-0.5x0)-((x.-x0).^2)./(2sigma^2))
V = ω^2*x.^2*m/2;
output = SplitStep(ψ,V,p, time);
Animates the real and imaginary components of $\psi$, and its magnitude
x_real = real.(x)
V_real = real.(V)
V1 = (ω^2*x_real.^2*m/2)/maximum(ω^2*x_real.^2*m/2)*maximum(abs2.(output[1,:]))
anim = @animate for i in 1:length(time)
plot(x_real, V1, label="trap", color=:gray, ls=:dash, xlabel =L"x", ylabel = L"|\Psi(x,t)|^2", ylim=(0,0.05))
plot!(x_real, real.(output[i,:]).^2, color=:red, label=L"Re\{ \Psi(t) \}^2")
plot!(x_real, imag.(output[i,:]).^2, color=:blue, label=L"Im\{ \Psi(t) \}^2")
plot!(x_real, abs2.(output[i,:]), color=:black, label = "t =$(i)")
end every 10
gif(anim, "KR2_anim_qm.gif", fps = FPS)
┌ Info: Saved animation to /Users/richellejadetuquero/Desktop/Physics215_MiniProject/KR2_anim_qm.gif └ @ Plots /Users/richellejadetuquero/.julia/packages/Plots/nuwp4/src/animation.jl:156
Let us create functions to make the comparison and benchmarking of the two methods (Quantum Optics and split-step) efficient. psi_t_solver solves using QuantumOptics.jl while split_step_method solves using a custom split-step method.
function psi_t_solver(m,ω,xmin,xmax, Npoints,x0, p0,sigma, time)
#Basis
b_position = PositionBasis(xmin, xmax, Npoints)
b_momentum = MomentumBasis(b_position)
# operators
x = position(b_position)
p = momentum(b_momentum)
px = transform(b_momentum, b_position) # position to momentum
xp = dagger(px)
K = LazyProduct(xp, p^2/2m, px) #kinetic energy
V = ω^2*x^2*m/2 # potential energy
H = LazySum(K, V) #Hamiltonian
psi0 = gaussianstate(b_position, x0, p0, sigma) #assume initial state is a gaussian function
t, psi_t = timeevolution.schroedinger(time, psi0, H);
return t,psi_t
end
function SplitStep(ψ, V, p, t_points, m; potential_evolution=x_coeff, kinetic_evolution=p_coeff)
#=
ψ: initial wavefunction
V: time independent potential
p: momentum
T: total time
Δt: time-step
=#
Δt = t_points[2]-t_points[1]
output = Array{Complex}(undef, length(t_points), length(ψ))
# Creates the empty output array. 1st dimension is time, including initial wvfcn, 2nd is position.
for (i, t) in enumerate(t_points)
output[i,:]=ψ[:] # Inputs the current content of ψ into the output
ψ=fft(potential_evolution(V, Δt).*ψ)
ψ=ifft(kinetic_evolution(p, Δt, m).*ψ)
ψ=potential_evolution(V,Δt).*ψ
end
output
end
x_coeff(V::Vector{ComplexF64}, Δt::Float64) = exp.(-im*V*Δt/2); # Creates the coefficient for position evolution
p_coeff(p::Vector{ComplexF64}, Δt::Float64, mass::Float64=1.) = exp.(-im*(p.^2)*Δt/(2mass)); # Creates the coefficient for momentum evolution
function split_step_method(m,ω,x_min,x_max, Npoints ,x0, p0,sigma, time)
#=
ψ: initial wavefunction
V: time independent potential
p: momentum
T: total time
Δt: time-step
=#
x = Vector{ComplexF64}(LinRange(x_min,x_max,Npoints));
Δx = x[2]-x[1]
p = 2π.*Vector{ComplexF64}(fftfreq(length(x), length(x)/abs(x[1]-x[end])));
#p or po
ψ = (sqrt(Δx)/(sqrt(sigma)*(π)^(1/4)))*exp.(im*p0*(x.-0.5x0)-((x.-x0).^2)./(2sigma^2))
V = ω^2*x.^2*m/2;
output = SplitStep(ψ,V,p,time, m);
return output
end
split_step_method (generic function with 1 method)
Observe that there points in time where two the wavefunctions slightly differ. This is because the split-step method is an approximation (i.e $\Delta t << 1$).
time = [0:0.01:20;];
res = Npoints
t, psi_qop = psi_t_solver(1.0, 2, -4, 4, res, 2, 0,0.6, time);
psi_ssm = split_step_method(1.0, 2, -4, 4, res, 2, 0,0.6, time);
ymax = abs.((sqrt(Δx)/(sqrt(0.6)*(π)^(1/4)))).^2
pt = @animate for i=1:length(time)
psi = psi_qop[i]
plot(x_points, abs.(psi.data).^2, ylims=(0,ymax), label="QuantumOptics")
plot!(x_points, abs.(psi_ssm[i,:]).^2, label="SplitStep", xlabel = L"x", ylabel = L"|\Psi(x, t)|^2")
end every 10
gif(pt, "KR3_two_method.gif", fps=10)
┌ Info: Saved animation to /Users/richellejadetuquero/Desktop/Physics215_MiniProject/KR3_two_method.gif └ @ Plots /Users/richellejadetuquero/.julia/packages/Plots/nuwp4/src/animation.jl:156
sum_qop = similar(abs.(psi_ssm[:,1]))
sum_ssm = similar(abs.(psi_ssm[:,1]))
for i in eachindex(time)
psi = psi_qop[i]
sum_qop[i] = sum(abs2.(psi.data))
sum_ssm[i] = sum(abs2.(psi_ssm[i,:]))
end
plot(time, sum_qop,linewidth = 3, xlabel="time", ylabel="total probability", ylim = (0.9,1), label="QuantumOptics")
plot!(time, sum_ssm, label="SplitStep", linestyle =:dash, linewidth = 3,ylim = (0.99, 1.01))
We confirm in the above result that the total probability is conserved and therefore shows that the simulations for both methods are working as expected. We note that the total probability must be 1 since there are no atom/s leaking out of the system, and we are dealing with a closed system.
We can then compare the two methods and check if they produce similar values.
x0::Float64 = 1.75
p0::Float64 = 0.0
psi0 = gaussianstate(b_x, x0, p0, sigma);
t, psi_Qopt = timeevolution.schroedinger(time, psi0, H);
ψ = (sqrt(Δx)/(sqrt(sigma)*(π)^(1/4)))*exp.(im*p0*(x.-0.5x0)-((x.-x0).^2)./(2sigma^2))
psi_SS = SplitStep(ψ,V,p, time);
V1 = (ω^2*x_points.^2*m/2)/maximum(ω^2*x_points.^2*m/2)*maximum(abs2.(psi0.data)) # Just for plotting the potential
anim = @animate for i in 1:length(time)
psi = psi_Qopt[i]
plot(x_points, V1, label="trap", color=:gray, ls=:dash, xlabel =L"x", ylabel = L"|\Psi(x,t)|^2", ylim=(0,0.035))
plot!(x_points,abs.(psi.data).^2 , lc=:red, label="QuantumOptics")
plot!(x_points, abs.(psi_SS[i,:]).^2, color=:blue, label = "Split Step")
end every 10
gif(anim, "KR4_comparison_evol.gif", fps = FPS)
┌ Info: Saved animation to /Users/richellejadetuquero/Desktop/Physics215_MiniProject/KR4_comparison_evol.gif └ @ Plots /Users/richellejadetuquero/.julia/packages/Plots/nuwp4/src/animation.jl:156
We can see that the two solutions produce similar values, but are slightly off in their frequencies, this can be overtly seen by plotting the values along $x=0$ over time.
Qopt_c = Array{Float64}(undef, length(time))
for i=1:length(time)
psi = psi_Qopt[i]
n = abs.(psi.data[Int64((end)//2)+1])
Qopt_c[i] = n
end
plot(time, abs.(psi_SS[:,Int64((end)//2)+1]).^2, label="Split Step")
plot!(time,Qopt_c.^2, xlabel = "time (s)", ylabel = L"|\Psi(0, t)|^2", label="QuantumOptics")
We can then overtly see that the two solutions have slightly different frequencies. To then see which one is more correct, we can compare then to a known analytic solution, the first order stationary solution to the quantum harmonic oscillator. We know that for the stationary solution, the value at $x=0$ is just a constant, the normalization factor.
x0::Float64 = 0.0
p0::Float64 = 0.0
psi0 = gaussianstate(b_x, x0, p0, sigma);
t, psi_Qopt = timeevolution.schroedinger(time, psi0, H);
ψ = (sqrt(Δx)/(sqrt(sigma)*(π)^(1/4)))*exp.(im*p0*(x.-0.5x0)-((x.-x0).^2)./(2sigma^2))
psi_SS = SplitStep(ψ,V,p, time);
Qopt_c = Array{Float64}(undef, length(time))
for i=1:length(time)
psi = psi_Qopt[i]
n = abs.(psi.data[Int64((end)//2+1)])
Qopt_c[i] = n
end
stat_soln = abs.((sqrt(Δx)/(sqrt(sigma)*(π)^(1/4)))).^2
plot(time, 100 .* abs.(stat_soln.-abs.(psi_SS[:,Int64((end)//2)+1]).^2)./stat_soln, label="Split Step")
plot!(time,100 .* abs.(stat_soln.-Qopt_c.^2)./stat_soln, label="QuantumOptics", xlabel = "time (s)",ylabel= "% difference at x = 0")
Since the initial state is the stationary case, we expect that the % difference of the simulation of the two methods must be close to zero. In the figure above, we observe that both method has a % difference of less than 1%. This shows that both method agrees with the theoretical prediction. We also note that between the two methods, the method that uses QuantumOptics has a more accurate result as compared to the Split Step method. This is because the QuantumOptics directly solve the Schroedinger equation using matrices in the form of bra and kets in their respective Hilbert space. Meanwhile, the Split Step method uses approximations and relies on the $\Delta t$ of the simulation. Therefore, we can observe a more accurate result for the Split Step as $\Delta t$ decreases.
Let us calculate for the minimum, median, and maximum execution time of psi_t_solver. Note that the macro @benchmark runs an expression (in this case the psi_t_solver) multiple times where it automatically chooses the right number of evaluations per sample for any given benchmark.
#long execution time
n_val = 100:50:1000
time_QuantOp_min = zeros(Float64, length(n_val))
time_QuantOp_Q1 = zeros(Float64, length(n_val))
time_QuantOp_median = zeros(Float64, length(n_val))
time_QuantOp_Q3 = zeros(Float64, length(n_val))
time_QuantOp_max = zeros(Float64, length(n_val))
memory_alloc_QuantOp = zeros(Float64, length(n_val))
for (index, npoints) in enumerate(n_val)
#psi_t_solver(m = 1.0,ω = 2,xmin = -4,xmax= 4, Npoints = npoints,x0 = 2, p0 = 0,sigma=0.6, time = [0:0.1:5;])
benchmark_result_QuantOp = @benchmark psi_t_solver(1.0, 2,-4,4, $npoints, 2, 0,0.6, [0:0.1:5;])
time_QuantOp_min[index] = minimum(benchmark_result_QuantOp.times)
time_QuantOp_Q1[index] = percentile(benchmark_result_QuantOp.times, 25)
time_QuantOp_median[index] = median(benchmark_result_QuantOp.times)
time_QuantOp_Q3[index] = percentile(benchmark_result_QuantOp.times, 75)
time_QuantOp_max[index] = maximum(benchmark_result_QuantOp.times)
memory_alloc_QuantOp[index] = benchmark_result_QuantOp.memory
end
Let us also calculate for the minimum, median, and maximum execution time of split_step_method, also using @benchmark.
n_val = 100:50:1000
time_splitstep_min = zeros(Float64, length(n_val))
time_splitstep_Q1 = zeros(Float64, length(n_val))
time_splitstep_median = zeros(Float64, length(n_val))
time_splitstep_Q3 = zeros(Float64, length(n_val))
time_splitstep_max = zeros(Float64, length(n_val))
memory_alloc_splitstep = zeros(Float64, length(n_val))
for (index, npoints) in enumerate(n_val)
#split_step_method(m = 1.0,ω = 2,xmin = -4,xmax= 4, Npoints = npoints,x0 = 2, p0 = 0,sigma=0.6, time = [0:0.1:5;])
benchmark_result_splitstep = @benchmark split_step_method(1.0, 2,-4,4, $npoints, 2, 0,0.6, [0:0.1:5;])
time_splitstep_min[index] = minimum(benchmark_result_splitstep.times)
time_splitstep_Q1[index] = percentile(benchmark_result_splitstep.times, 25)
time_splitstep_median[index] = median(benchmark_result_splitstep.times)
time_splitstep_Q3[index] = percentile(benchmark_result_splitstep.times, 75)
time_splitstep_max[index] = maximum(benchmark_result_splitstep.times)
memory_alloc_splitstep[index] = benchmark_result_splitstep.memory
end
Let us now compare the of the two methods for $Npoints = \{100, 150, 200, 250, 300, \ldots, 900, 950,1000\}$.
The two figures below (second figure presents the y-axis in the logarithmic scale) shows the execution time of the two methods -- using QuantumOptics.jl and using a custom split-step method. For both methods, we show the minimum, first quartile, median, third quartile, and maximum execution time. QOP refers to the execution time when we use QuantumOptics.jl while SS refers to the split-step method. Observe that there is only one marker for the Quantum Optics method whereas we expected $5$. This is due @benchmark choosing the appropriate number of samples to be $1$ for the Quantum Optics method.
Observe that the maximum execution time of the split-step method seems to be constant function with respect to $N$, while the minimum and median time seems like a logarithmic function. More importantly, comparing the two methods, observe that the Quantum Optics method has a longer execution time for all $N \in \mathrm{Npoints}$.
plot(n_val, time_QuantOp_median/(10^(9))/60 ,seriestype=:scatter, label = "QOP median", markershape = :hline, markercolor=:green)
plot(n_val, time_QuantOp_min/(10^(9))/60 ,seriestype=:scatter, label = "QOP min", markershape = :hline, markercolor=:green)
plot(n_val, time_QuantOp_Q1/(10^(9))/60 ,seriestype=:scatter, label = "QOP Q1", markershape = :hline, markercolor=:green)
plot(n_val, time_QuantOp_Q3/(10^(9))/60 ,seriestype=:scatter, label = "QOP Q3", markershape = :hline, markercolor=:green)
plot(n_val, time_QuantOp_max/(10^(9))/60 ,seriestype=:scatter, label = "QOP max", markershape = :hline, markercolor=:green)
plot!(n_val, time_splitstep_median/(10^(9))/60 ,seriestype=:scatter, label = "SS median", markershape = :hline, markercolor=:red)
plot!(n_val, time_splitstep_Q1/(10^(9))/60 ,seriestype=:scatter, label = "SS Q1", markershape = :hline, markercolor=:red)
plot!(n_val, time_splitstep_Q3/(10^(9))/60 ,seriestype=:scatter, label = "SS Q3", markershape = :hline, markercolor=:red)
plot!(n_val, time_splitstep_min/(10^(9))/60 ,seriestype=:scatter, label = "SS min", markershape = :hline, markercolor=:red)
plot!(n_val, time_splitstep_max/(10^(9))/60 ,seriestype=:scatter, label = "SS max", markershape = :hline, markercolor=:red)
# title!("Npoints versus median time")
xlabel!("N")
ylabel!("Execution time (minutes)")
# plot!(yaxis=:log, legend =:topleft)
plot(n_val, time_QuantOp_median/(10^(9))/60 ,seriestype=:scatter, label = "QOP median", markershape = :hline, markercolor=:green)
plot(n_val, time_QuantOp_min/(10^(9))/60 ,seriestype=:scatter, label = "QOP min", markershape = :hline, markercolor=:green)
plot(n_val, time_QuantOp_Q1/(10^(9))/60 ,seriestype=:scatter, label = "QOP Q1", markershape = :hline, markercolor=:green)
plot(n_val, time_QuantOp_Q3/(10^(9))/60 ,seriestype=:scatter, label = "QOP Q3", markershape = :hline, markercolor=:green)
plot(n_val, time_QuantOp_max/(10^(9))/60 ,seriestype=:scatter, label = "QOP max", markershape = :hline, markercolor=:green)
plot!(n_val, time_splitstep_median/(10^(9))/60 ,seriestype=:scatter, label = "SS median", markershape = :hline, markercolor=:red)
plot!(n_val, time_splitstep_Q1/(10^(9))/60 ,seriestype=:scatter, label = "SS Q1", markershape = :hline, markercolor=:red)
plot!(n_val, time_splitstep_Q3/(10^(9))/60 ,seriestype=:scatter, label = "SS Q3", markershape = :hline, markercolor=:red)
plot!(n_val, time_splitstep_min/(10^(9))/60 ,seriestype=:scatter, label = "SS min", markershape = :hline, markercolor=:red)
plot!(n_val, time_splitstep_max/(10^(9))/60 ,seriestype=:scatter, label = "SS max", markershape = :hline, markercolor=:red)
# title!("Npoints versus median time")
xlabel!("N")
ylabel!("Execution time (minutes)")
plot!(yaxis=:log, legend =:topleft)
Observe that for $N\leq 500$, the split step method require more memory relative to the QuantumOptics method. For $N > 500$, the opposite is observed.
plot(n_val, memory_alloc_QuantOp ,seriestype=:scatter, label = "QOP", markershape = :circle, markercolor=:green)
plot!(n_val, memory_alloc_splitstep ,seriestype=:scatter, label = "SS", markershape = :circle, markercolor=:red)
xlabel!("N")
ylabel!("Total memory allocated")
# plot!(yaxis=:log, legend =:topleft)
We were able to simulate a one-dimensional system with a harmonic trap using two methods. These are the QuantumOptics method which takes advantage of the julia library to solve quantum systems, and the Split Step method. Both of these methods gave acceptable results and matches that of the analytical prediction. Upon comparison, we note that the QuantumOptics method gave far accurate result than the Split Step method. However, the Split Step method results to faster execution time and lesser memory allocation for $N>500$ points.
[1] S. Krämer, D. Plankensteiner, L. Ostermann and H. Ritsch. QuantumOptics. jl: A Julia framework for simulating open quantum systems Comp. Phys. Comm. 227, 109-116 (2018)
[2] H. Gould, J. Tobochnik, W. Christian. An Introduction to Computer Simulation Methods 3rd ed. (2016)